# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time      :2022/8/2 0002 0:33
# @Author    :jiaxuesong


#创建用例执行文件
#导包
import unittest
import time
from common.log import logger
from selenium.webdriver.common.by import By
from appium_test.common.myTest import MyTest
from appium_test.common.readData import ReadExcle
from PO.littleMsgPage import LittleMsgPage


#定义测试用例类
class TestClass(MyTest):
    #定义测试用例类
    def test_anormal(self):
        # 获取类名
        c_name = self.__class__.__name__
        # 获取方法名
        m_name = self._testMethodName
        # 实例化调用读取数据文件的方法
        rea = ReadExcle()
        case_data = rea.read(c_name, m_name)
        # 编写测试用例
        operation = LittleMsgPage(self.driver)
        operation.clickSerchBox()
        operation.clearSerchBox()
        operation.inputSerchMsg(case_data)
        operation.clickSerchButton()
        time.sleep(5)
        #断言
        assert 'Appium' in self.driver.page_source
        logger.info('用例1执行成功')

    def test_bmax(self):
        # 获取类名
        c_name = self.__class__.__name__
        # 获取方法名
        m_name = self._testMethodName
        # 实例化调用读取数据文件的方法
        rea = ReadExcle()
        case_data = rea.read(c_name, m_name)
        # 编写测试用例
        operation = LittleMsgPage(self.driver)
        operation.Serch_all(case_data)
        time.sleep(5)
        #断言
        assert 'Appium' in self.driver.page_source
        logger.info('用例2执行成功')

    def test_cmin(self):
        # 获取类名
        c_name = self.__class__.__name__
        # 获取方法名
        m_name = self._testMethodName
        # 实例化调用读取数据文件的方法
        rea = ReadExcle()
        case_data = rea.read(c_name, m_name)
        # 编写测试用例
        operation = LittleMsgPage(self.driver)
        operation.Serch_all(case_data)
        time.sleep(5)
        #断言
        assert 'Appium' in self.driver.page_source
        logger.info('用例3执行成功')

if __name__ == '__main__':
    unittest.main()